package homework;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @classname:demo09
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/16 17:41
 * @version: 0.1
 * @since:1.8
 */
public class demo09 {
    public static void main(String[] args) {
       String path = "D:\\mulu\\student_info.txt";
        List<Student> list = new ArrayList<>(10);

        try(
                BufferedReader reader  = new BufferedReader(new FileReader(path));
                ){

            String info = "";
            while((info=reader.readLine())!=null){
                String[] split = info.split("-");
                String name = split[0];
                String id = split[1];
                String score = split[2];
                list.add(new Student(name,Integer.parseInt(id),Integer.parseInt(score)));
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        //reversed方法倒转排序
        Collections.sort(list,Comparator.comparing(Student::getScore).reversed().thenComparing((stu1,stu2)->stu2.getAge().compareTo(stu2.getAge())));

        System.out.println(list);
    }
}
